export function formatTime(time) {
    if (
        (time[4] == '-' && time[7] == '-' &&
            time.at(-3) == ':' && time.at(-6) == ':' &&
            time.length > 17 && time.length < 20 &&
            /^[^a-zA-Z]+$/.test(time) &&
            Number(time.at(-8) + time.at(-7)) < 24 &&
            Number(time.at(-5) + time.at(-4)) < 60 &&
            Number(time.at(-2) + time.at(-1)) < 60 &&
            Number(time[5] + time[6]) < 13 &&
            Number(time[8] + time[9]) < 32
        )
        ||
        (time.length == 10 && time[4] == '-' && time[7] == '-'
            && Number(time[5] + time[6]) < 13)
        && Number(time[8] + time[9]) < 32
        ||
        (time.toString().includes('GMT+0800')) && time.toString().length == 42) {
        return new Date(time).getTime()
    } else {
        let isTime = /^\d{13}$/;
        if (isTime.test(time)) {
            var date = new Date(time);
            var Y = date.getFullYear() + "-";
            var M = (date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1) + "-";
            var D = (date.getDate() < 10 ? "0" + date.getDate() : date.getDate()) + " ";
            var h = date.getHours() < 10 ? "0" + date.getHours() : date.getHours() + ":";
            var m = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes() + ":";
            var s = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
            return Y + M + D + h + m + s;
        } else {
            return time
        }
    }
}
